/**
*      author: Y_Yao
*      created: 2024-12-21 20:04:12
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 100 + 7;
int h,w;
int x,y;
char a[N][N];
string T;
bool vis[N][N];

void solve()
{
    cin >> h >> w >> x >> y;
    for(int i = 1;i <= h;i++)
    {
        for(int j = 1;j <= w;j++)
        {
            cin >> a[i][j];
        }
    }
    cin >> T;
    int n = T.size();
    T = " " + T;

    int ans = 0;
    if(a[x][y] == '@') ans++;
    for(int i = 1;i <= n;i++)
    {
        if(T[i] == 'U' && a[x-1][y]!='#')
        {
            if(a[x-1][y] == '@' && !vis[x-1][y])
            {
                ans++;
                vis[x-1][y] = 1;
            }
            x = x - 1;
        }
        else if(T[i] == 'D' && a[x+1][y]!='#')
        {
            if(a[x+1][y] == '@' && !vis[x+1][y])
            {
                vis[x+1][y] = 1;
                ans++;
            }
            x = x + 1;
        }
        else if(T[i] == 'L' && a[x][y-1]!='#')
        {
            if(a[x][y-1] == '@' && !vis[x][y-1])
            {
                vis[x][y-1] = 1;
                ans++;
            }
            y = y - 1;
        }
        else if(T[i] == 'R' && a[x][y+1]!='#')
        {
            if(a[x][y+1] == '@' && !vis[x][y+1])
            {
                vis[x][y+1] = 1;
                ans++;
            }
            y = y + 1;
        }
    }
    cout << x << " " << y << " " << ans << endl;;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}